package com.wnxy.eleba.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.eleba.entity.Order;
import com.wnxy.eleba.mapper.OrderMapper;
import com.wnxy.eleba.service.OrderService_zhuying;
import com.wnxy.eleba.vo.OrderQueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class OrderServiceImpl_zhuying implements OrderService_zhuying {

    private OrderMapper orderMapper;

    @Autowired
    public void setOrderMapper(OrderMapper orderMapper) {
        this.orderMapper = orderMapper;
    }

    @Override
    public Order findOrderById(Integer orderId) {
        return orderMapper.selectByPrimaryKey(orderId);
    }

    @Override
    public List<Order> findAll() {
        return orderMapper.selectAll();
    }

    @Override
    public PageInfo<Order> listOrderPageByCondition(OrderQueryParam orderQueryParam) {
        PageHelper.startPage(orderQueryParam.getCurrentPage(),orderQueryParam.getPageSize());
        List<Order> orderList=orderMapper.selectOrderCondition(orderQueryParam);
        PageInfo<Order> pageInfo = new PageInfo<>(orderList);

        return pageInfo;
    }

    @Override
    public boolean saveOrder(Order Order) {
        return orderMapper.insert(Order)!=0;
    }

    @Override
    public boolean updateOrder(Order Order) {
        return orderMapper.updateByPrimaryKey(Order)!=0;
    }

    @Override
    public boolean deleteOrder(Integer[] ids) {
        return false;
    }

    @Override
    public boolean delOrder(Integer id) {
        return orderMapper.deleteByPrimaryKey(id)!=0;
    }

    @Override
    public List<String> listOrderType() {
        return null;
    }
}
